<?php
    @include_once("conn.php");

    // 1. 根据学员的姓名  进行模糊搜索 


    $key = $_GET["key"];
    $orderCol = $_GET["orderCol"]; // column 列名   id/chinese/math/english /total
    $orderType = $_GET["orderType"]; //排序类型 asc desc 

    $search = "select *,chinese+math+english as total  from `grade` where name like '%$key%' order by $orderCol $orderType";

    $result = mysqli_query($conn,$search);

    // print_r($result);  // 结果对象(object)   php对象取值  对象->属性名
    // echo $result->num_rows;

    $all = array();
    while($item = mysqli_fetch_assoc($result)){
        // $item["chinese"] =$item["chinese"]*1;
        array_push($all,$item);
    }

    echo json_encode($all);



?>